package commonDataStructures;

import java.util.ArrayList;

/**
 * @author avishl02
 * this class represents an queue
 * @param <E>
 */
public class PrimitiveQueue<E> implements PrimitiveCollection<E>{
	
	private ArrayList<E> _queue;
	
	//ctor
	public PrimitiveQueue(){
		_queue = new ArrayList<E>();
	}
	
	//insert element
	public void insert(E e) {
		_queue.add(e);
		
	}
	
	//copy another queue with some limitations
	public void copy(PrimitiveQueue<E> other,int limit){
		int len = Math.min(limit,other.size());
		for(int i=0;i<len;i++){
			_queue.add(other._queue.get(i));
		}
	}

	
	/* (non-Javadoc)
	 * @see ai.ex1.DataStructures.PrimitiveCollection#isEmpty()
	 */
	public boolean isEmpty() {
		return _queue.isEmpty();
	}

	/* (non-Javadoc)
	 * @see ai.ex1.DataStructures.PrimitiveCollection#remove()
	 */
	public E remove() {
		return _queue.remove(0);
	}
	
	/* (non-Javadoc)
	 * @see ai.ex1.DataStructures.PrimitiveCollection#size()
	 */
	public int size() {
		return _queue.size();
	}

	@Override
	public void init() {
		_queue.clear();
		
	}

}
